import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:untitled/pages/home/tab_search/filter_bar/data.dart';
//过滤bar的Model
class FilterBarModel extends Model{
  //可选数据列表
  List<GeneralType> _roomTypeList = [];
  List<GeneralType> _orientedList = [];
  List<GeneralType> _floorList = [];

  Set<String> _selectedList = new Set<String>();//选中数据列表

  //获取可选数据列表
  Map<String,List<GeneralType>> get dataList{
    var result = Map<String,List<GeneralType>>();
    result['roomTypeList'] = _roomTypeList;
    result['orientedList'] = _orientedList;
    result['floorList'] = _floorList;
    return result;
  }

  //设置可选数据列表
  set dataList(Map<String,List<GeneralType>> data){
    _roomTypeList = data['roomTypeList'];
    _orientedList = data['orientedList'];
    _floorList = data['floorList'];
  }

  //获取选择数据列表
  Set<String> get selectedList{
    return _selectedList;
  }
  //添加或修改选中数据列表中的值
  selectedListToggleItem(String data){
    if(_selectedList.contains(data)){
      _selectedList.remove(data);
    }else{
      _selectedList.add(data);
    }
    //通知观察者
    notifyListeners();
  }
}
